package org.luckyjourney.controller.booking;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.luckyjourney.entity.booking.dto.*;
import org.luckyjourney.entity.booking.vo.OrderPaymentVO;
import org.luckyjourney.entity.booking.vo.OrderVO;
import org.luckyjourney.service.booking.OrdersService;
import org.luckyjourney.util.PageResult;
import org.luckyjourney.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/luckyjourney/orders")
@Api(tags = "订单")
@Slf4j
public class OrdersController {

    @Autowired
    OrdersService ordersService;

    @PutMapping("/cancel")
    @ApiOperation("取消订单")
    public Result CancelOrder(@RequestBody OrdersCancelDTO ordersCancelDTO) {
        ordersService.CancelOrder(ordersCancelDTO);
        return Result.success();
    }

    @PostMapping("/details")
    @ApiOperation("查看订单详情")
    public Result DetailsOrder(@RequestBody OrdersCancelDTO ordersCancelDTO) {
        OrderVO orderVo = ordersService.DetailsOrder(ordersCancelDTO);
        return Result.success(orderVo);
    }

    @PostMapping("/delectOrder")
    @ApiOperation("删除订单")
    public Result DelectOrder(@RequestBody OrdersCancelDTO ordersCancelDTO) {
        ordersService.DelectOrder(ordersCancelDTO);
        return Result.success();
    }

    @PostMapping("/Page")
    @ApiOperation("订单列表")
    public Result selectPage(@RequestBody OrdersDTO ordersDTO) {
        Page<OrderVO> page = ordersService.selectPage(ordersDTO);
        return Result.success(page);
    }

}
